<?php

/**
 * This is the model class for table "tmedicos".
 *
 * The followings are the available columns in table 'tmedicos':
 * @property integer $PK_Tmedicos
 * @property string $nombre
 * @property integer $cod_especialidad
 * @property string $horario_atencion
 * @property string $fecha_alta
 * @property string $fecha_baja
 * @property double $valor_cita
 */
class Medicos extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return Medicos the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'tmedicos';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('PK_Tmedicos, cod_especialidad', 'numerical', 'integerOnly'=>true),
			array('valor_cita', 'numerical'),
			array('nombre', 'length', 'max'=>250),
			array('horario_atencion', 'length', 'max'=>30),
			array('fecha_alta, fecha_baja', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('PK_Tmedicos, nombre, cod_especialidad, horario_atencion, fecha_alta, fecha_baja, valor_cita', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'PK_Tmedicos' => 'Pk Tmedicos',
			'nombre' => 'Nombre',
			'cod_especialidad' => 'Cod Especialidad',
			'horario_atencion' => 'Horario Atencion',
			'fecha_alta' => 'Fecha Alta',
			'fecha_baja' => 'Fecha Baja',
			'valor_cita' => 'Valor Cita',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('PK_Tmedicos',$this->PK_Tmedicos);
		$criteria->compare('nombre',$this->nombre,true);
		$criteria->compare('cod_especialidad',$this->cod_especialidad);
		$criteria->compare('horario_atencion',$this->horario_atencion,true);
		$criteria->compare('fecha_alta',$this->fecha_alta,true);
		$criteria->compare('fecha_baja',$this->fecha_baja,true);
		$criteria->compare('valor_cita',$this->valor_cita);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}